package CtrlLayer;
import java.io.IOException;
import java.util.List;

import ModelLayer.Customer;
import ModelLayer.Employee;
import ModelLayer.PersonContainer;
import ModelLayer.Supplier;

/**
 * Write a description of class PersonCtrl here.
 * 
 * @author (ucn-1semprojekt-dm78-gruppe1) 
 * 
 */
public class PersonCtrl
{
	private PersonContainer PC;
	
	public PersonCtrl()
	{
		PC = PersonContainer.getInstance();
	}

	public void loadFromFile() throws IOException, ClassNotFoundException
	{
		PC.loadFromFile();
	}
	
	public void saveToFile() throws IOException
	{
		PC.saveToFile();
	}
	
	public void createCustomer(String name, String address, String postal, String city, String phone, String email, int craftsmanDiscount)
	{
    	Customer myCustomer = new Customer(name, address, postal, city, phone, email, craftsmanDiscount);
    	PC.addCustomer(myCustomer);
	}

	public void createEmployee(String name, String address, String postal, String city, String phone, String email, String username, String password)
	{
		Employee myEmployee = new Employee(name, address, postal, city, phone, email, username, password);
    	PC.addEmployee(myEmployee);
	}
	
	public void createSupplier(String name, String address, String postal, String city, String phone, String email, String companyName, int creditornr)
	{
		Supplier mySupplier = new Supplier(name, address, postal, city, phone, email, companyName, creditornr);
		PC.addSupplier(mySupplier);
	}
	
	public Customer searchCustomer(String phone)
    {
		return PC.getCustomer(phone);
    }
	
	public Employee searchEmployee(String phone)
    {
		return PC.getEmployee(phone);
    }
	
	public Supplier searchSupplier(String phone)
    {
		return PC.getSupplier(phone);
    }
	
	public List<Supplier> getSupplierList()
	{
		return PC.getSupplierList();
	}
	
	public List<Customer> getCustomerList()
	{
		return PC.getCustomerList();
	}
	
	public List<Employee> getEmployeeList()
	{
		return PC.getEmployeeList();
	}
	
	public Employee getFEmployee()
    {
		return PC.getFirstEmployee();
	}
}
